fd33c55d992098c1f06ef7135a03e78e43cbe021,cdap-data-fabric/src/main/java/co/cask/cdap/data2/datafabric/dataset/service/executor/DatasetAdminService.java,DatasetAdminService,createOrUpdate,#Id.DatasetInstance#DatasetTypeMeta#DatasetProperties#DatasetSpecification#,97

Before Change


    try (DatasetClassLoaderProvider classLoaderProvider =
           new DirectoryClassLoaderProvider(cConf, locationFactory)) {

      return impersonator.doAs(datasetInstanceId.getNamespace().toEntityId(), new Callable<DatasetSpecification>() {
        @Override
        public DatasetSpecification call() throws Exception {
          DatasetType type = dsFramework.getDatasetType(typeMeta, null, classLoaderProvider);

After Change


    try (DatasetClassLoaderProvider classLoaderProvider =
           new DirectoryClassLoaderProvider(cConf, locationFactory)) {
      final DatasetContext context = DatasetContext.from(datasetInstanceId.getNamespaceId());
      UserGroupInformation ugi = impersonator.getUGI(datasetInstanceId.getNamespace().toEntityId());

      final DatasetType type = ImpersonationUtils.doAs(ugi, new Callable<DatasetType>() {
        @Override
        public DatasetType call() throws Exception {
          DatasetType type = dsFramework.getDatasetType(typeMeta, null, classLoaderProvider);
          if (type == null) {
            throw new BadRequestException(
              String.format("Cannot instantiate dataset type using provided type meta: %s", typeMeta));
          }
          return type;
        }
      });

      DatasetSpecification spec = ImpersonationUtils.doAs(ugi, new Callable<DatasetSpecification>() {
        @Override